#include "learn_gvc.h"

int test_gvc1(int argc, char** argv)
{
	GVC_t* gvc;
	Agraph_t* g;
	FILE* fp;
	gvc = gvContext();
	if (argc > 1)
		fp = fopen(argv[1], "r");
	else
		fp = stdin;
	g = agread(fp, 0);
	gvLayout(gvc, g, "dot");
	gvRender(gvc, g, "plain", stdout);
	gvFreeLayout(gvc, g);
	agclose(g);
	return (gvFreeContext(gvc));
}

int test_gvc2(int argc, char** argv)
{
	Agraph_t* g, * prev = NULL;
	GVC_t* gvc;
	gvc = gvContext();
	gvParseArgs(gvc, argc, argv);
	while ((g = gvNextInputGraph(gvc))) {
		if (prev) {
			gvFreeLayout(gvc, prev);
			agclose(prev);
		}
		gvLayoutJobs(gvc, g);
		gvRenderJobs(gvc, g);
		prev = g;
	}
	return (gvFreeContext(gvc));
}
